package org.budo.jdbc.driver;

import java.sql.SQLException;
import java.sql.Types;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * @author lmw
 */
@Accessors(fluent = true)
@Getter
@Setter
public class BudoJdbcResultSetMetaData extends AbstractBudoJdbcResultSetMetaData {
    private String[] columnNames;

    private String[] columnLabels;

    private int[] columnTypes;

    private String[] columnClassNames;

    public BudoJdbcResultSetMetaData() {}

    public BudoJdbcResultSetMetaData(String[] columnNames) {
        this.columnNames(columnNames);
    }

    public int getColumnCount() throws SQLException {
        return this.columnNames().length;
    }

    @Override
    public int getScale(int column) throws SQLException {
        return 0;
    }

    @Override
    public int getPrecision(int column) throws SQLException {
        return 0;
    }

    public String getColumnName(int column) throws SQLException {
        return this.columnNames()[column - 1];
    }

    @Override
    public String getColumnLabel(int column) throws SQLException {
        return this.getColumnName(column);
    }

    @Override
    public int getColumnType(int column) throws SQLException {
        return Types.VARCHAR;
    }

    @Override
    public String getColumnClassName(int column) throws SQLException {
        return String.class.getName();
    }

    @Override
    public String getSchemaName(int column) throws SQLException {
        return "";
    }

    @Override
    public String getTableName(int column) throws SQLException {
        return "";
    }

    @Override
    public int getColumnDisplaySize(int column) throws SQLException {
        return Integer.MAX_VALUE;
    }
}
